package com.org.mapper;

import com.org.entity.AuthUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Rainy-Heights
 * @version 1.0
 * @Date 2023/2/23 21:08
 */


public interface UserMapper {

    @Select("select * from renjiancihua.user where username = #{username}")
    AuthUser getPasswordByUsername(String username);

    @Select("select  *from renjiancihua.user where username=#{username} and password=#{password}")
    AuthUser getByNameAndPassword(@Param("username") String username,@Param("password") String password);

    @Insert("insert into  renjiancihua.user(username, role, password) values(#{username},#{role},#{password})")
    int registerUser(AuthUser user);//可以传入对象，直接赋值

    //设置传参来实现注册
    @Insert("insert into  renjiancihua.user(username, role, password) values(#{username},#{role},#{password})")
    int registerUserByEveryParam(@Param("username") String username,@Param("role")String role,@Param("password") String password);

    @Insert("INSERT INTO renjiancihua.userinfo(name, gender) VALUES (#{name},#{gender})")
    int insertInfo(@Param("name") String name, @Param("gender") String gender);

    @Select("select * from renjiancihua.user where password=#{password}")
    List<AuthUser> getLoginByPwd(String password);

    @Select("select * from renjiancihua.user where username=#{username} and password=#{password}")
    List<AuthUser> getLoginOrNot(@Param("username") String username,@Param("password") String password);

}
